package pojo;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity; //规范entity
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor;

@Entity
@Table(name="customersss")  //定制表名
@GenericGenerator(name="ang",strategy="uuid")
public class Customer {
//	@GeneratedValue(generator="angersq",strategy=GenerationType.SEQUENCE)
//	@SequenceGenerator(name="angersq",sequenceName="anger_sqe",initialValue=1, allocationSize=1)
	@Id
//	@GenericGenerator(name="ang",strategy="uuid")
//	@GeneratedValue(generator="ang")
	private String id;
//	@EmbeddedId
//	private FullName fullName;
	
	@Column(name="cname", nullable=true, length=40,insertable=true,updatable=true, unique=false )
	private String name;
	@Transient  //不由jpa管理，不存入数据库
	private int age;
	@Column(columnDefinition="char(1)")
	private boolean sex;
	@Temporal(TemporalType.TIMESTAMP)
	private Date birth;
//	@Embedded
//	private Address address;
	@ElementCollection(fetch=FetchType.EAGER)
	@JoinTable(name="tels",joinColumns=@JoinColumn(name="c_id"))
	@Column(name="tel_code")
	private Set<String> telphone = new HashSet<>();
	
	@ElementCollection(fetch=FetchType.LAZY)
	@JoinTable(name="adds",joinColumns=@JoinColumn(name="add_id"))
	@JoinColumn()
	private Set<Address> addresses = new HashSet<Address>();
	public Set<String> getTelphone() {
		return telphone;
	}
	public void setTelphone(Set<String> telphone) {
		this.telphone = telphone;
	}
	
	public Set<Address> getAddresses() {
		return addresses;
	}
	public void setAddresses(Set<Address> addresses) {
		this.addresses = addresses;
	}
	//	@Lob
//	@Basic(fetch=FetchType.LAZY)
//	private byte[] img;
//	
//	
//	public byte[] getImg() {
//		return img;
//	}
//	public void setImg(byte[] img) {
//		this.img = img;
//	}
	public Date getBirth() {
		return birth;
	}
	public void setBirth(Date birth) {
		this.birth = birth;
	}
	public Customer(String id, String name, int age, boolean sex) {
		super();
//		this.id = id;
		this.name = name;
		this.age = age;
		this.sex = sex;
	}
	public Customer() {
		// TODO Auto-generated constructor stub
	}
	public boolean isSex() {
		return sex;
	}
	public void setSex(boolean sex) {
		this.sex = sex;
	}
	
//	public FullName getFullName() {
//		return fullName;
//	}
//	public void setFullName(FullName fullName) {
//		this.fullName = fullName;
//	}
			public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
		
}
